{% extends 'base.html' %}
{% load staticfiles %}


{% block base_title %}
    操作日志
{% endblock base_title %}


{% block base_header_css %}
    <!-- 弹框详情css -->
    <style>
        .popover-title {
            color: #1c2b36;
            font-weight: bolder;
        }

        .popover {
            background-color: #1c2b36;
            color: white;
        }
    </style>
{% endblock base_header_css %}


{% block base_content %}
    <div class="app-content">
        <div class="app-content-body fade-in-up">
            <div class="padder" style="padding-top: 10px;">

                <div class="col-md-12" style="padding-left: 0; padding-right: 0;">
                    <div class="panel panel-default" id="body-content">
                        <div class="panel-heading">
                            <div style="display: block; border-left: 5px solid #1c2b36; padding-left: 10px; font-size: 20px; font-weight: bolder; line-height: 25px;color: #1c2b36;">
                                操作日志{% ifnotequal keyword '' %}&nbsp;&nbsp;
                                ："{{ keyword }}" 关键字搜索结果{% endifnotequal %}
                            </div>
                        </div>

                        <div class="panel-body" id="table_content">

                            <!-- 功能 -->
                            <div style="padding-bottom: 15px;">
                                <a class="btn btn-sm {% ifequal user_check 'all' %}btn-dark{% else %}btn-default{% endifequal %}"
                                   href="?&user_check=all">显示全部</a>
                                <a class="btn btn-sm {% ifequal user_check 'add' %}btn-dark{% else %}btn-default{% endifequal %}"
                                   href="?&user_check=add">只看添加</a>
                                <a class="btn btn-sm {% ifequal user_check 'edit' %}btn-dark{% else %}btn-default{% endifequal %}"
                                   href="?&user_check=edit">只看修改</a>
                                <a class="btn btn-sm {% ifequal user_check 'up' %}btn-dark{% else %}btn-default{% endifequal %}"
                                   href="?&user_check=up">只看启用</a>
                                <a class="btn btn-sm {% ifequal user_check 'down' %}btn-dark{% else %}btn-default{% endifequal %}"
                                   href="?&user_check=down">只看停用</a>

                                <form class="navbar-form pull-right" role="search" style="margin-top: 0;">
                                    <div class="form-group">
                                        <div class="input-group">
                                            <input type="text" class="form-control input-sm bg-light no-border rounded"
                                                   placeholder="关键词查找记录" name="keyword" style="width: 150px;">
                                            <span class="input-group-btn">
                                    <button type="submit" class="btn btn-sm bg-auto rounded">
                                        <i class="fa fa-search"></i>
                                    </button>
                                </span>
                                        </div>
                                    </div>
                                </form>
                                <span style="font-size: 14px; padding-top: 5px;" class="pull-right">共 <b
                                        style="color: orangered">{{ record_nums }}</b> 条</span>
                            </div>

                            <!-- 列表 -->
                            <div class="row">
                                <div class="col-sm-12">
                                    <table class="table table-striped table-bordered" style="table-layout: fixed;">
                                        <!-- 标题行 -->
                                        <thead>
                                        <tr role="row">
                                            <th width="5" style="padding: 0;"></th>
                                            <th class="text-center" width="60">ID</th>
                                            <th class="text-center" width="200">操作用户名</th>
                                            <th class="text-center" width="200">操作用户中文名</th>
                                            <th class="text-center" width="150">操作</th>
                                            <th class="text-center">操作详情</th>
                                            <th class="text-center" width="300">操作日期</th>
                                        </tr>
                                        </thead>
                                        <tbody>

                                        {% if records.object_list %}
                                            {% for each_record in records.object_list %}
                                                <tr class="gradeX {% if forloop.counter|divisibleby:2 %}odd{% else %}even{% endif %}"
                                                    role="row">
                                                    <td style="
                                                            {% ifequal each_record.operation 1 %} background-color: #1bd1a5; {% endifequal %}
                                                            {% ifequal each_record.operation 2 %} background-color: #003366; {% endifequal %}
                                                            {% ifequal each_record.operation 3 %} background-color: #ff7500; {% endifequal %}
                                                            {% ifequal each_record.operation 4 %} background-color: #ff2d51; {% endifequal %}">
                                                    </td>
                                                    <td class="text-center">{{ forloop.counter }}</td>
                                                    <td class="text-center">{{ each_record.op_user.username }}</td>
                                                    <td class="text-center">{{ each_record.op_user.chinese_name }}</td>
                                                    <td class="text-center">{{ each_record.get_operation_display }}</td>
                                                    <td class="text-center">{{ each_record.action }}</td>
                                                    <td class="text-center">{{ each_record.add_time }}</td>
                                                </tr>
                                            {% endfor %}
                                        {% else %}
                                            <tr class="gradeX even"
                                                role="row">
                                                <td class="text-center" colspan="10">暂无记录</td>
                                            </tr>
                                        {% endif %}

                                        </tbody>
                                    </table>
                                </div>
                            </div>

                        </div>

                        <!-- 页码 -->
                        <div class="panel-footer" style="padding-top: 0; padding-bottom: 0;">
                            <div class="text-center">
                                <ul class="pagination" style="margin-top: 10px; margin-bottom: 10px;">

                                    <!-- 上一页 -->
                                    {% if records.has_previous %}
                                        <li><a href="?{{ records.previous_page_number.querystring }}">上一页<span
                                                class="sr-only"></span></a></li>
                                        <li><a href="?{{ records.previous_page_number.querystring }}">&laquo;<span
                                                class="sr-only"></span></a></li>
                                    {% endif %}

                                    <!-- 页码 -->
                                    {% for page in records.pages %}
                                        {% if page %}
                                            <!-- 当前页 -->
                                            {% ifequal page records.number %}
                                                <li class="active"><a href="?page={{ page }}">{{ page }}<span
                                                        class="sr-only">(current)</span></a></li>
                                                <!-- 其它页 -->
                                            {% else %}
                                                <li><a href="?page={{ page }}">{{ page }}<span
                                                        class="sr-only"></span></a></li>
                                            {% endifequal %}
                                            <!-- 省略页 -->
                                        {% else %}
                                            <li><a href="">...<span class="sr-only"></span></a></li>
                                        {% endif %}
                                    {% endfor %}

                                    <!-- 下一页 -->
                                    {% if records.has_next %}
                                        <li><a href="?{{ records.next_page_number.querystring }}">&raquo;<span
                                                class="sr-only"></span></a></li>
                                        <li><a href="?{{ records.next_page_number.querystring }}">下一页<span
                                                class="sr-only"></span></a></li>
                                    {% endif %}
                                </ul>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
{% endblock base_content %}


{% block base_footer_js %}
    <!-- 记录详情 -->
    <script>
        $(function () {
            $("[data-toggle='popover']").popover();
        });
    </script>
{% endblock base_footer_js %}







